package com.aibaixun.web.controller.system;

import com.aibaixun.common.annotation.Log;
import com.aibaixun.common.core.domain.R;
import com.aibaixun.common.enums.BusinessType;
import com.aibaixun.system.domain.SysFile;
import com.aibaixun.system.service.SysFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 系统文件管理Controller
 *
 * @author zhangyh
 * @create 2023/10/27
 */
@RestController
@RequestMapping("/file" )
@Api(value = "sysFile", tags = "系统文件管理Controller")
public class SysFileController {

    @Autowired
    private SysFileService sysFileService;

    /**
     * 统一文件上传接口
     * @param file
     * @return
     */
    @ApiOperation("统一文件上传接口")
    @PostMapping(path = "/common/upload")
    @Log(title = "系统文件管理-统一文件上传", businessType = BusinessType.INSERT)
    public R<SysFile> uploadFile(@RequestPart("file") @ApiParam("文件信息") MultipartFile file
    ) {
        return sysFileService.uploadFile(file);
    }
}
